package com.songshuai.pangu.api.controller;

import com.songshuai.pangu.api.service.CustMeetingService;
import com.songshuai.webapi.baseapi.dto.feign.request.custminiprogram.*;
import com.songshuai.webapi.baseapi.dto.feign.response.custminiprogram.*;
import com.songshuai.webapi.baseapi.enumerations.ResultStatus;
import com.songshuai.webapi.baseapi.model.custminiprogram.MeetingPicture;
import com.songshuai.webapi.baseapi.pojo.QueryResponse;
import com.songshuai.webapi.baseapi.utils.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author:wbl
 * @Date: 2019/3/20
 */
@Slf4j
@Api("活动中心")
@RestController
@RequestMapping("/api/custmeeting/")
public class CustMeetingController{

    @Autowired
    private CustMeetingService custMeetingService;

    @ApiOperation(value = "根据客户Id获取会议列表")
    @GetMapping("getMeetingListByUserId")
    public QueryResponse<List<MeetingListResDto>> getMeetingListByUserId(@RequestParam("customId") String customId){
        try {
            List<MeetingListResDto> resList = custMeetingService.getMeetingListByUserId(customId);
            if (null != resList){
                return QueryResponse.setResData(resList);
            }
        } catch (Exception ex) {
            log.error("/api/custmeeting/getMeetingListByUserId", ex);
            return new QueryResponse<>(ResultStatus.FAILOfficial.getErrorCode(),ex.getMessage());
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @ApiOperation(value = "根据会议编号,邀约编号获取会议详情")
    @PostMapping("getMeetingDetail")
    public QueryResponse<MeetingDetailResDto> getMeetingDetail(@RequestBody MeetingDetailReqDto parm){
        try {
            MeetingDetailResDto meetingDetailResDto = custMeetingService.getMeetingDetail(parm);
            if (null != meetingDetailResDto){
                return QueryResponse.setResData(meetingDetailResDto);
            }
        } catch (Exception ex) {
            log.error("/api/custmeeting/getMeetingDetail", ex);
            return new QueryResponse<>(ResultStatus.FAILOfficial.getErrorCode(),ex.getMessage());
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @ApiOperation(value = "根据会议编号获取邀约模板")
    @GetMapping("getInvitationTemplateByCode")
    public QueryResponse<List<InvitationTemplateResDto>> getInvitationTemplateByCode(@RequestParam("meetingCode") String meetingCode){
        try {
            List<InvitationTemplateResDto> resList = custMeetingService.getInvitationTemplateByCode(meetingCode);
            if (null != resList){
                return QueryResponse.setResData(resList);
            }
        } catch (Exception ex) {
            log.error("/api/custmeeting/getInvitationTemplateByCode", ex);
            return new QueryResponse<>(ResultStatus.FAILOfficial.getErrorCode(),ex.getMessage());
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @ApiOperation(value = "根据线索id和会议编号获取签到码")
    @PostMapping("getWxQRCode")
    public QueryResponse<WxQRCodeResDto> getWxQRCode(@RequestBody WxQRCodeReqDto parm){
        try {
            WxQRCodeResDto resDto = custMeetingService.getWxQRCode(parm);
            if (null != resDto){
                return QueryResponse.setResData(resDto);
            }
        } catch (Exception ex) {
            log.error("/api/custmeeting/getWxQRCode", ex);
            return new QueryResponse<>(ResultStatus.FAILOfficial.getErrorCode(),ex.getMessage());
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @ApiOperation(value = "校验签到码(待定)")
    @GetMapping("registerSign")
    public QueryResponse<Boolean> registerSign(@RequestParam("clueguid") Long clueguid,
                                               @RequestParam("meetingno") String meetingno,
                                               @RequestParam("timestamp") String timestamp,
                                               @RequestParam("hashcode") String hashcode){
        Boolean result = true;
        return QueryResponse.setResData(result);
    }

    @ApiOperation(value = "新增签到码签到（待定）")
    @PostMapping("QRCodeSign")
    public QueryResponse<Boolean> QRCodeSign(@RequestBody QRCodeSignReqDto parm){
        Boolean result = true;
        return QueryResponse.setResData(result);
    }

    @ApiOperation(value = "根据邀约编号获取回执单")
    @PostMapping("getMeetingReceipt")
    public QueryResponse<MeetingReceiptResDto> getMeetingReceipt(@RequestBody MeetingReceiptReqDto parm){
        try {
            MeetingReceiptResDto meetingReceiptResDto = custMeetingService.getMeetingReceipt(parm);
            if (null != meetingReceiptResDto){
                return QueryResponse.setResData(meetingReceiptResDto);
            }
        } catch (Exception ex) {
            log.error("/api/custmeeting/getMeetingReceipt", ex);
            return new QueryResponse<>(ResultStatus.FAILOfficial.getErrorCode(),ex.getMessage());
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @ApiOperation(value = "新增回执单")
    @PostMapping("addMeetingReceipt")
    public QueryResponse<AddMeetingReceiptResDto> addMeetingReceipt(@RequestBody AddMeetingReceiptReqDto parm){
        try {
            AddMeetingReceiptResDto addMeetingReceiptResDto = custMeetingService.addMeetingReceipt(parm);
            if (null != addMeetingReceiptResDto){
                return QueryResponse.setResData(addMeetingReceiptResDto);
            }
        } catch (Exception ex) {
            log.error("/api/custmeeting/addMeetingReceipt", ex);
            return new QueryResponse<>(ResultStatus.FAILOfficial.getErrorCode(),ex.getMessage());
        }
        return new QueryResponse<>(ResultStatus.ERROR_CREATE_FAILED);
    }

    /*@ApiOperation(value = "根据字典类型获取字典信息")
    @GetMapping("getDictionaryByTypeId")
    public QueryResponse<List<DictionaryResDto>> getDictionaryByTypeId(@RequestParam("dicType") Integer dicType){
        List<DictionaryResDto> resList = new ArrayList<>();
        DictionaryResDto resDto = new DictionaryResDto();
        resDto.setId(1);
        resDto.setName("标准间");
        resDto.setParentId(0);
        resDto.setTypeId(10);
        resDto.setTypeName("房间类型");
        resDto.setTypeRemark("酒店房间");
        resDto.setSort(10);
        resList.add(resDto);
        return QueryResponse.setResData(resList);
    }*/

    @ApiOperation(value = "根据会议编号获取车站信息")
    @GetMapping("getAreaStations")
    public QueryResponse<List<StationResDto>> getAreaStations(@RequestParam("meetingCode") String meetingCode){
        try {
            List<StationResDto> resList = custMeetingService.getAreaStations(meetingCode);
            if (null != resList){
                return QueryResponse.setResData(resList);
            }
        } catch (Exception ex) {
            log.error("/api/custmeeting/getAreaStations", ex);
            return new QueryResponse<>(ResultStatus.FAILOfficial.getErrorCode(),ex.getMessage());
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @ApiOperation(value = "获取全部车站信息（待定）")
    @GetMapping("getAllStations")
    public QueryResponse<List<StationResDto>> getAllStations(){
        List<StationResDto> resList = new ArrayList<>();
        StationResDto resDto = new StationResDto();
        resDto.setId(1);
        resDto.setStationName("虹桥飞机场");
        resDto.setSort(10);
        resList.add(resDto);
        return QueryResponse.setResData(resList);
    }

    @ApiOperation(value = "根据id获取车站信息（待定）")
    @GetMapping("getStationById")
    public QueryResponse<StationResDto> getStationById(@RequestParam("id") Integer id){
        StationResDto resDto = new StationResDto();
        resDto.setId(1);
        resDto.setStationName("虹桥飞机场");
        resDto.setSort(10);
        return QueryResponse.setResData(resDto);
    }
}
